class_name HoldDevilSpear
extends BaseHoldItem

@onready var muzzle: Marker2D = $Muzzle


func shoot():
	var config = item_data.item_config as ItemGunBaseConfig
	var player = holder as Player
	
	var bullet_inst = (ResourceManager.get_resource("bullet_devil_spear") as PackedScene).instantiate() as RigidBody2D
	player.level.bullets_parent.add_child(bullet_inst)
	bullet_inst.global_position = muzzle.global_position
	bullet_inst.rotation = muzzle.global_rotation
	
	bullet_inst.sender = player
	bullet_inst.attack = config.attack + player.player_data.get_attack()
	bullet_inst.critical_rate = config.critical_rate
	bullet_inst.critical_bonus = config.critical_bonus
	bullet_inst.knockback = config.knockback
	bullet_inst.hit_cam_shake_intensity = config.attack_cam_shake_intensity
	bullet_inst.hit_cam_shake_duration = config.attack_cam_shake_duration
	bullet_inst.level = player.level
	bullet_inst.steal_hp_rate = config.steal_hp_rate
	bullet_inst.set_is_enemy(false)
	
	var shoot_direction = Vector2.from_angle(player.gun_hand.global_rotation)
	bullet_inst.set_start_velocity(shoot_direction * config.shoot_start_speed)
